<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <script src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <script src="../js/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>


    <style>
        .layui-table td {
            min-width: 50px !important;
        }
    </style>
    <script>
        $(function () {
            // alert("ss")
            to_page(1)
        })

        function to_page(pn) {
            $.ajax({
                url: "user/bankfindall",
                type: "GET",
                data: {
                    "pn": pn
                },
                dataType: "json",
                success: function (result) {
                    //查询所有用户
                    findalluser(result)
                    build_page_info(result)
                    build_page_nav(result)
                }
            })
        }

        //显示所有用户
        function findalluser(result) {
            $("#emps_table tbody").empty();
            var users = result.list;
            $.each(users, function (index, n) {
                var userId = $("<td></td>").append(n.userId);
                var userName = $("<td></td>").append(n.userName);
                var tel = $("<td></td>").append(n.tel);
                var idCard = $("<td></td>").append(n.idCard);
                var sex = $("<td></td>").append(n.sex);
                var birth = $("<td></td>").append(n.birth);
                // var ismarry = $("<td></td>").append(n.ismarry);
                var status = $("<td></td>").append(n.typeName);
                var createime = $("<td></td>").append(n.createTime);
                var editBtn = $("<button></button>").addClass("btn btn-primary btn-sm edit_btn")
                    .append($("<span></span>").addClass("glyphicon glyphicon-pencil")).append("审核");
                editBtn.attr("edit-id", n.userId);
                var btnTd = $("<td></td>").append(editBtn);
                $("<tr></tr>")
                    .append(userId)
                    .append(userName)
                    .append(tel)
                    .append(idCard)
                    .append(sex)
                    .append(birth)
                    // .append(ismarry)
                    .append(status)
                    .append(createime)
                    .append(btnTd)
                    .appendTo("#emps_table tbody");

            });

        }

        //显示分页条数据
        function build_page_info(result) {
            $("#page_info_area").empty()
            $("#page_info_area").append("当前" + result.pageNum + "页,总" +
                result.pages + "页,总" +
                result.total + "条记录");

        }

        //显示导航条数据
        function build_page_nav(result) {
            //page_nav_area
            $("#page_nav_area").empty();
            var ul = $("<ul></ul>").addClass("pagination");

            //构建元素
            var firstPageLi = $("<li></li>").append($("<a></a>").append("首页").attr("href", "#"));
            var prePageLi = $("<li></li>").append($("<a></a>").append("&laquo;"));
            if (result.hasPreviousPage == false) {
                firstPageLi.addClass("disabled");
                prePageLi.addClass("disabled");
            } else {
                //为元素添加点击翻页的事件
                firstPageLi.click(function () {
                    to_page(1);
                });
                prePageLi.click(function () {
                    to_page(result.pageNum - 1);
                });
            }
            var nextPageLi = $("<li></li>").append($("<a></a>").append("&raquo;"));
            var lastPageLi = $("<li></li>").append($("<a></a>").append("末页").attr("href", "#"));
            if (result.hasNextPage == false) {
                nextPageLi.addClass("disabled");
                lastPageLi.addClass("disabled");
            } else {
                nextPageLi.click(function () {
                    to_page(result.pageNum + 1);
                });
                lastPageLi.click(function () {
                    to_page(result.pages);
                });
            }


            //添加首页和前一页 的提示
            ul.append(firstPageLi).append(prePageLi);
            //1,2，3遍历给ul中添加页码提示
            $.each(result.navigatepageNums, function (index, item) {

                var numLi = $("<li></li>").append($("<a></a>").append(item));
                if (result.pageNum == item) {
                    numLi.addClass("active");
                }
                numLi.click(function () {
                    to_page(item);
                });
                ul.append(numLi);
            });
            //添加下一页和末页 的提示
            ul.append(nextPageLi).append(lastPageLi);

            //把ul加入到nav
            var navEle = $("<nav></nav>").append(ul);
            navEle.appendTo("#page_nav_area");

        }

        $(document).on("click", ".edit_btn", function () {
            // alert("edit");
            //1、查出资历信息
            getData($(this).attr("edit-id"));
            // 根据id查询用户信息
            getUser($(this).attr("edit-id"));

            //
            // //3、把员工的id传递给模态框的更新按钮
            // $("#emp_update_btn").attr("edit-id",$(this).attr("edit-id"));
            $("#empUpdataModal").modal({
                backdrop: "static"
            });
            display();
        });
        function display(){

            $(document).on("change","#passor",function(){
                // alert("sss")
                var check = $('#empUpdataModal input[name=pass]:checked').val();
                // alert(check)
                if(check==0){
                    $("#reasondiv").attr("style","display:block;");//显示div
                    $("#result").attr("readonly",true)
                }else{
                    $("#reasondiv").attr("style","display:none;");//隐藏div
                    $("#result").attr("readonly",false)
                }
            })
        }

        function getUser(id) {
            var userid = id;
            $.ajax({
                url: "user/selectid/" + id,
                type: "get",
                dataType: "json",
                success: function (result) {

                    $("#truename").val(result.trueName)
                    $("#sex").val(result.sex)
                    $("#birth").val(result.birth)
                    $("#tel").val(result.tel)
                    $("#industry").val(result.industry)
                    // $("#education").val(result.sex)   //学历
                    $("#ismarry").val(result.ismarry)
                    $("#industry").val(result.industry)
                    // $("#succreqnum").val(result.succ_req_num)

                    $("#idcard").val(result.idCard)

                    // $("#empUpdataModal input[name=gender]").val([result.gender]);
                    // $("#empUpdataModal select").val([result.did])
                    // $("#empName_add_inputupdata").val(result.name)
                }
            })
        }

        function getData(id) {
            var userid = id;
            $.ajax({

                url: "user/selectdataid/" + userid,
                type: "get",
                dataType: "json",
                success: function (result) {
                    // alert(result.education)

                    $("#education").val(result.education)
                    $("#repayment").val(result.repayment)
                    $("#guarantor").val(result.guarantor)
                    $("#guarantortel").val(result.guarantortel)
                    $("#createtime").val(result.createTime)
                    // $("#education").val(result.sex)   //学历
                    $("#guarantorrelation").val(result.guarantorRelation)
                    $("#dfid").val(result.dfId)
                    // $("#succreqnum").val(result.succ_req_num)

                    $("#idfv").attr("src", result.idfv)
                    $("#idrv").attr("src", result.idrv)
                    $("#propertyOwnership").attr("src", result.propertyOwnership)
                    $("#vehicleLicense").attr("src", result.vehicleLicense)
                    // $("#empUpdataModal input[name=pass]").val([result.gender]);

                }
            })
        }

        $(document).on("click", "#emp_save_btnupdata", function () {
            // alert("sss")
            // var assessmenttypea=$("")
            // alert( $('#empUpdataModal input[name=pass]:checked').val())
            var check = $('#empUpdataModal input[name=pass]:checked').val();
            var dfid = $('#dfid').val();
            var result=$("#result").val();
            var commentB=$("#reason").val();
            $.ajax({
                url: "user/bankupdata",
                type: "GET",
                data: {
                    "check": check,
                    "dfId": dfid,
                    "result":result,
                    "commentB":commentB
                },
                success: function (resp) {
                    // alert(resp)

                    $("#empUpdataModal").modal('hide')
                    $("#page_info_area").empty();
                    $("#page_nav_area").empty();
                    $(".layui-card-body").empty();
                    $("#z1").load("http://localhost:8086/jump?url=view/bank-list.html");
                }
            })
        })

        $(document).on("click","#find",function(){
            // alert("ss")
            var key=$("#search").val();
            $.ajax({
                url:"user/search",
                type:"GET",
                data:{
                    "key":key
                },
                dataType:"json",
                success:function(resp){
                    // alert(resp)

                    findalluser(resp)
                    build_page_info(resp)
                    build_page_nav(resp)
                }
            })
        })

    </script>
</head>

<body>
<div class="modal fade" id="empUpdataModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document" style="width:1000px; height:600px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabelupdata">审核</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="addformupdata">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">状态</label>
                        <div class="col-sm-3">
                            <input type="text" name="name" class="form-control" id="#" readonly>
                            <span class="help-block"></span>
                        </div>

                        <label class="col-sm-2 control-label">创建时间</label>
                        <div class="col-sm-5">
                            <input type="text" name="name" class="form-control" id="createtime" placeholder="empName"
                                   readonly>
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <!--                        <label class="col-sm-2 control-label">email</label>-->
                        <!--                        <div class="col-sm-10">-->
                        <!--                            <input type="text" name="email" class="form-control" id="email_add_inputupdata" placeholder="email@atguigu.com">-->
                        <!--                            <span class="help-block"></span>-->
                        <!--                        </div>-->
                        <label class="col-sm-1 control-label">姓名</label>
                        <div class="col-sm-2">
                            <input type="hidden" id="dfid"/>
                            <input type="text" name="name" class="form-control" id="truename" placeholder="" readonly>
                            <!--                            <span>ss</span>-->
                            <span class="help-block"></span>
                        </div>
                        <label class="col-sm-1 control-label">性别</label>
                        <div class="col-sm-2">
                            <input type="text" name="name" class="form-control" id="sex" placeholder="" readonly>
                            <span class="help-block"></span>
                        </div>
                        <label class="col-sm-1 control-label">出生日期</label>
                        <div class="col-sm-2">
                            <input type="text" name="name" class="form-control" id="birth" placeholder="" readonly>
                            <span class="help-block"></span>
                        </div>
                        <label class="col-sm-1 control-label">手机</label>
                        <div class="col-sm-2">
                            <input type="text" name="name" class="form-control" id="tel" placeholder="" readonly>
                            <span class="help-block"></span>
                        </div>


                    </div>
                    <div class="form-group">
                        <!--                        <label class="col-sm-2 control-label">email</label>-->
                        <!--                        <div class="col-sm-10">-->
                        <!--                            <input type="text" name="email" class="form-control" id="email_add_inputupdata" placeholder="email@atguigu.com">-->
                        <!--                            <span class="help-block"></span>-->
                        <!--                        </div>-->
                        <label class="col-sm-1 control-label">学历</label>
                        <div class="col-sm-2">
                            <input type="text" name="name" class="form-control" id="education" placeholder="" readonly>
                            <span class="help-block"></span>
                        </div>
                        <label class="col-sm-1 control-label">是否结婚</label>
                        <div class="col-sm-2">
                            <input type="text" name="name" class="form-control" id="ismarry" placeholder="" readonly>
                            <span class="help-block"></span>
                        </div>
                        <label class="col-sm-1 control-label">行业</label>
                        <div class="col-sm-2">
                            <input type="text" name="name" class="form-control" id="industry" placeholder="" readonly>
                            <span class="help-block"></span>
                        </div>
                        <label class="col-sm-1 control-label">还款来源</label>
                        <div class="col-sm-2">
                            <input type="text" name="name" class="form-control" id="repayment" placeholder="" readonly>
                            <span class="help-block"></span>
                        </div>


                    </div>
                    <div class="form-group">
                        <label class="col-sm-1 control-label">身份证号</label>
                        <div class="col-sm-2">
                            <input type="text" name="name" class="form-control" id="idcard" placeholder="" readonly>
                            <span class="help-block"></span>
                        </div>
                        <label class="col-sm-1 control-label">联系人</label>
                        <div class="col-sm-2">
                            <input type="text" name="name" class="form-control" id="guarantor" placeholder="" readonly>
                            <span class="help-block"></span>
                        </div>
                        <label class="col-sm-1 control-label">联系人手机</label>
                        <div class="col-sm-2">
                            <input type="text" name="name" class="form-control" id="guarantortel" placeholder=""
                                   readonly>
                            <span class="help-block"></span>
                        </div>
                        <label class="col-sm-1 control-label">联系人关系</label>
                        <div class="col-sm-2">
                            <input type="text" name="name" class="form-control" id="guarantorrelation" placeholder=""
                                   readonly>
                            <span class="help-block"></span>
                        </div>


                    </div>
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-2 control-label">身份证正面</label>-->
<!--                        <div class="col-sm-10">-->
<!--                            &lt;!&ndash;                            <input type="text" name="name" class="form-control"   readonly>&ndash;&gt;-->
<!--                            <img id="idfv" src=""/>-->
<!--                            <span class="help-block"></span>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-2 control-label">身份证反面</label>-->
<!--                        <div class="col-sm-10">-->
<!--                            &lt;!&ndash;                            <input type="text" name="name" class="form-control" id="w"  readonly>&ndash;&gt;-->
<!--                            <img id="idrv" src=""/>-->
<!--                            <span class="help-block"></span>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-2 control-label">房产信息</label>-->
<!--                        <div class="col-sm-10">-->
<!--                            &lt;!&ndash;                            <input type="text" name="name" class="form-control" id="w"  readonly>&ndash;&gt;-->
<!--                            <img id="propertyOwnership" src=""/>-->
<!--                            <span class="help-block"></span>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-2 control-label">车辆信息</label>-->
<!--                        <div class="col-sm-10">-->
<!--                            &lt;!&ndash;                            <input type="text" name="name" class="form-control" id="vehicleLicense"  readonly>&ndash;&gt;-->
<!--                            <img id="vehicleLicense" src=""/>-->
<!--                            <span class="help-block"></span>-->
<!--                        </div>-->
<!--                    </div>-->

                    <div class="form-group">
                        <label class="col-sm-2 control-label">授信额度</label>
                        <div class="col-sm-10">
                            <input type="text" name="name" class="form-control" id="result">
                            <span class="help-block"></span>
                        </div>
                    </div>
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-2 control-label">身份证信息是否正确</label>-->
<!--                        <div class="col-sm-10" id="idcardor">-->
<!--                            <label class="radio-inline">-->
<!--                                <input type="radio" name="idcard" id="idcard1" value="是" checked="checked"> 是-->
<!--                            </label>-->
<!--                            <label class="radio-inline">-->
<!--                                <input type="radio" name="idcard" id="idcard2" value="否"> 否-->
<!--                            </label>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-2 control-label">车辆信息是否正确</label>-->
<!--                        <div class="col-sm-10" id="caror">-->
<!--                            <label class="radio-inline">-->
<!--                                <input type="radio" name="car" id="car1" value="是" checked="checked"> 是-->
<!--                            </label>-->
<!--                            <label class="radio-inline">-->
<!--                                <input type="radio" name="car" id="car2" value="否"> 否-->
<!--                            </label>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-2 control-label">房产信息是否正确</label>-->
<!--                        <div class="col-sm-10" id="houseor">-->
<!--                            <label class="radio-inline">-->
<!--                                <input type="radio" name="house" id="house1" value="是" checked="checked"> 是-->
<!--                            </label>-->
<!--                            <label class="radio-inline">-->
<!--                                <input type="radio" name="house" id="house2" value="否"> 否-->
<!--                            </label>-->
<!--                        </div>-->
<!--                    </div>-->
                    <div class="form-group">
                        <label class="col-sm-2 control-label">是否通过</label>
                        <div class="col-sm-10" id="passor">
                            <label class="radio-inline">
                                <input type="radio" name="pass" id="pass1" value="1" checked="checked"> 通过
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="pass" id="pass2" value="0"> 不通过
                            </label>
                        </div>
                    </div>
                    <div class="form-group" id="reasondiv" hidden>
                        <label class="col-sm-2 control-label">未通过原因:</label>
                        <div class="col-sm-4">
                            <input type="text" name="reason" class="form-control" id="reason" >
                            <span class="help-block"></span>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" id="btncloseupdata">关闭</button>
                <button type="button" class="btn btn-primary" id="emp_save_btnupdata">提交</button>
            </div>
        </div>
    </div>
</div>

<!--<div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">演示</a>
                <a>
                    <cite>导航元素</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>-->
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body " id="z1">
                    <form class="layui-form layui-col-space5" id="form1">
                        <div class="layui-input-inline layui-show-xs-block">
                            <input type="text" name="name" class="form-control" id="search" placeholder="用户名/身份证号"/>

                            <!--                            <select name="contrller" id="payType">-->
                            <!--                                <option value="">业务类型</option>-->
                            <!--                                <option value="1">非交易类型</option>-->
                            <!--                                <option value="2">交易类业务</option>-->
                            <!--                                <option value="3">额度内过桥业务</option>-->
                            <!--                            </select>-->
                        </div>
                        <div class="layui-input-inline layui-show-xs-block">
                            <button id="find" class="layui-btn" lay-submit="" lay-filter="sreach" type="button">
                                <i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </form>
                </div>
                <!--                <div class="layui-card-header">-->
                <!--                    <button class="layui-btn"-->
                <!--                            onclick="xadmin.open('录单','add.html',$(window).width()*0.9,$(window).height() - 50)">-->
                <!--                        <i class="layui-icon"></i>录单-->
                <!--                    </button>-->
                <!--                </div>-->
                <div class="layui-card-body " >
                    <table class="layui-table layui-form" id="emps_table">
                        <thead>
                        <tr>
                            <th th:width="60px">序号</th>
                            <th>客户姓名</th>
                            <th>手机号码</th>
                            <th>身份证号</th>
                            <th th:width="60px">性别</th>
                            <th>出生日期</th>
<!--                            <th>是否结婚</th>-->
                            <th>状态</th>
                            <th>申请时间</th>
                            <th id="t1">操作</th>
                        </tr>
                        </thead>
                        <tbody class="templateTbody">

                        </tbody>
                    </table>
                </div>

                <div class="layui-card-body ">
                    <div class="page">
                        <!--                        &lt;!&ndash;显示分页条&ndash;&gt;-->
                        <!--                        &lt;!&ndash;分页文字信息  &ndash;&gt;-->
                        <!--                        <div class="col-md-6" id="page_info_area"></div>-->
                        <!--                        &lt;!&ndash; 分页条信息 &ndash;&gt;-->
                        <!--                        <div class="col-md-6" id="page_nav_area">-->
                        <!--                            <div id="page">-->
                        <!--                            </div>-->
                        <!--                        </div>-->

                        <div class="row">
                            <div class="row">
                                <!--分页文字信息  -->
                                <div class="col-md-6" id="page_info_area"></div>
                                <!-- 分页条信息 -->
                                <div class="col-md-6" id="page_nav_area">

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['laydate', 'form'], function () {
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });
        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });
</script>

</html>
<!--<script src="../js/jquery.min.js"></script>-->
<!--<script src="../js/common/ajaxcommon.js"></script>-->
<!--<script src="../js/fangjs/ordislist.js"></script>-->